/*
 * @Descripttion: 啦啦啦哈哈哈
 * @version:
 * @Author: lsy
 * @Date: 2021-09-23 13:45:27
 * @LastEditors: liushengyan
 * @LastEditTime: 2023-03-16 15:30:09
 */

global.app.post("/api/login", (req, res) => {
  let sql = `SELECT id,userName,realName FROM user where userName='${req.body.username}' and password='${req.body.password}';`;
  console.log("查询",req.body,sql);
  // res.json({
  //   code: 200,
  //   message: "成功",
  //   token: "qwewqe1131231",
  //   data: { name: "张三", age: 10 },
  // });
  global.pool.getConnection((err, conn) => {
    if (err) {
      console.log("err", err);
    }
    conn.query(sql, (er, result) => {
      if (er) {
        console.log("err", er);
      }
      console.log(result);
      res.json({
        code: 200,
        message: "成功",
        token: "qwewqe1131231",
        data: result,
      });
      conn.release();
    });
  });
});
